﻿using Ekton_Manage_DomainCore.Aggregate;
using Ekton_Manage_DTO.RequestModels.SysUser;
using Ekton_Manage_DTO.RequestModels.User;
using Ekton_Manage_IBusiness;
using Ekton_Manage_InfrastructureCore.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Ekton_Manage_Web.Controllers
{
    /// <summary>
    /// 前端用户信息
    /// </summary>
    /// 
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize("Permission")]
    public class ApiUserInfoController : ControllerBase
    {
      
        private readonly IApiSelectUserInfo _apiSelectUserInfo;
        public ApiUserInfoController(IApiSelectUserInfo apiSelectUserInfo)
        {
            _apiSelectUserInfo = apiSelectUserInfo;
        }

        /// <summary>
        /// 查看账户信息
        /// </summary>
        /// 
        [HttpPost("{id}")]
        public async Task<Message> ApiGetUserInfo(int id)
        {
            return await _apiSelectUserInfo.Getaccountn(id);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// 
        [HttpPut]
        public async Task<Message> ApiPutUserPassword([FromBody] ApiDtoInsertUserPass request)
        {

            return await _apiSelectUserInfo.ApiPutUserPassword(request);
        }

        /// <summary>
        /// 修改账户信息
        /// </summary>
        /// 
        [HttpPut]
        public async Task<Message> ApiPutUserInfo([FromBody] ApiDtoInsertSysUser request)
        {
            return await _apiSelectUserInfo.ApiPutUserInfo(request);      
        }

    }
}
